extends Node


func shake(thing:Node2D,strength:float,duration:float=0.2)->void:
	if !thing:return 

	var startPos:=thing.position
	var shakeCount:=10
	var tween:=create_tween()

	for i in shakeCount:
		var offset:=Vector2(randf_range(-0.1,1.0),randf_range(-1.0,1.0))
		var target:=startPos+strength*offset
		if i % 2 == 0:target=startPos
		var opacity=sin(i)*0.5+0.5
		tween.tween_property(thing,'position',target,duration/float(shakeCount))
		tween.tween_property(thing,'modulate:a',opacity,duration/float(shakeCount))
		strength*=0.75
	await tween.finished
	thing.position=startPos
	thing.modulate.a=1


	


